<template>
    <div>
        <el-table :data="secklist" border style="width: 100%">
            <el-table-column prop="title" label="活动名称" width="180">
            </el-table-column>
            <el-table-column  label="状态" width="180">
                <template slot-scope="item">
                    <div>
                        <el-tag type="success" v-if="item.row.status">
                            启用
                        </el-tag>
                        <el-tag v-else type="danger">禁用</el-tag>
                    </div>
                </template>
            </el-table-column>
            <el-table-column  label="操作">
                <template slot-scope="item">
                    <div>
                        <el-button plain  type="primary"  @click="edit(item.row.id)">编辑</el-button>
                        <el-button plain    type="danger" @click="del(item.row.id)">删除</el-button>
                    </div>
                </template>
            </el-table-column>
        </el-table>
    </div>
</template>

<script>
import { seckDel } from '@/request/api';
// 引入辅助函数
import {mapActions,mapGetters} from 'vuex'
export default {
    data() {
        return {
        }
    },
    computed:{
        ...mapGetters({
            secklist:'seck/getSeckList'
        })
    },
    mounted(){
        this.getSeck()
    },
    methods:{
        ...mapActions({
            getSeck:'seck/changeSeckAction'
        }),
        // 编辑
        edit(id){
            this.$emit('edit',id)
        },
        // 删除
        del(id){
            // console.log('删除');
            this.$confirm('你确定要删除这条数据吗？','提示',{
                confirmButtonText:'确定',
                cancelButtonText:'取消',
                type:'warning',
            }).then(()=>{
                // 调用删除接口
                seckDel({id}).then(res=>{
                    console.log(res,'删除秒杀');
                    if(res.code == 200){
                        this.$message.success(res.msg)
                        this.getSeck()
                    }
                })
            })
        }
    }
};
</script>

<style scoped>
</style>
